<template>
	<view class="bgFF">
		<view class="bgIndex ">




		</view>
		<view class="certificationInformation">


			<view class="padding-top_15rpx" style="margin-left:212rpx; ">

				<!-- <image @click="clk(0)" class="avatar" style="border-radius: 50%;" :src="urls[0]" mode="">

				</image>
				<avatar style="position: absolute;" @upload="myUpload" ref="avatar"></avatar> -->
				<image class="avatar" style="border-radius: 50%;" :src="form.avatar" mode=""></image>

				请上传真实认证，可提升关注度
			</view>
			<view class="margin-bottom_40rpx" style="margin-top: 70rpx;">
				<pro-gress :list="Steps" :StepInfo='StepInfo'></pro-gress>
			</view>
			<!-- 认证基本资料 -->
			<view class="" v-show="step==1">
				<view class="borderTwo" style="padding: 40rpx 40rpx; padding-left: 20rpx;">
					<view class="higeys flex-wujustify">
						<view style="width:180rpx;">
							昵称
						</view>
						<view class="">
							<input class="uni-input" :disabled="true" type="text" v-model="form.nickname"
								placeholder="请输入昵称/称呼" />
						</view>


					</view>
					<view class=" myNmae flex-wujustify higeys">
						<view style="width:180rpx;">
							年龄
						</view>
						<view class="">
							<input class="uni-input" type="number" v-model="form.age" placeholder="请输入年龄" />
						</view>


					</view>
					<view class=" myNmae flex-wujustify higeys">
						<view style="width:180rpx;">
							手机号
						</view>
						<view class="">
							<input class="uni-input" maxlength="11" name="phone" type="text" v-model="form.phoneNumber"
								placeholder="请输入手机号" />
						</view>


					</view>

					<!-- <view class=" myNmae flex-between margin-top_40rpx">
					    <view class=" ">
					    	验证码
					    </view>
						<view class=" flex  ">
						
							<input  style="margin-left: 90rpx;"  v-model="form.sms_code" type="number"   placeholder="请输入验证码" />
						
						
							
						
						</view>
					    <view class="verificationCode" @click="getVerificationCode()">
					    	{{ count ? count + '秒' : '获取验证码' }}</view>
					
					</view> -->
					<view class="margin-top_40rpx" style="margin-top: 20rpx;">
						<view class="margin-bottom_30rpx">
							语音介绍
						</view>
						<view class="voiceIntroduction flex" @click="voiceRecordingFn()">
							{{form.speech?'✔ 已经添加语音':'+ 添加语音'}}
						</view>


					</view>
					<view class=" myNmae flex-wujustify higeys">
						<view style="width:180rpx;">
							个人介绍
						</view>
						<view class="">
							<input class="uni-input" type="text" v-model="form.introduce" placeholder="介绍一下自己吧" />
						</view>


					</view>
				</view>
				<view class="borderTwo" style="padding: 35rpx 40rpx;">

					<view class="flex-wujustify higeys">
						<view style="width:180rpx;">
							你的性别
						</view>
						<radio-group v-model="form.sex" name="apply" @change="radioChange">
							<!-- <label class="m-right10">
								<radio :checked="form.sex ==0" class="min-radio" value="0" color="#67C23A" />
								<text>性别不限</text>
							</label> -->
							<label class="m-right10">
								<radio :checked="form.sex ==1" class="min-radio" value="1" color="#67C23A" />
								<text style="font-size: 28rpx;">男</text>
							</label>
							<label style="margin-left: 30rpx;">
								<radio :checked="form.sex ==2" class="min-radio" value="2" color="#67C23A" />
								<text style="font-size: 28rpx;">女</text>
							</label>
						</radio-group>
					</view>

					<view class="higeys">
						<picker mode="date" :value="date" :fields="currentTimeFn(currentTime)" :start="startDate"
							:end="endDate" @change="bindDateChange">
							<view class="  flex-between">

								<view class="flex-wujustify myNmae">

									<view style="width:180rpx;">
										生日
									</view>

									<view class="flex-align-center-justify-start  ">
										<view class="" v-if="yeartime&&monthtime&&daytime">
											{{ yeartime }}
											<text>-</text>
											{{ monthtime }}
											<text>-</text>
											{{ daytime }}
											<!-- <uni-icons type="right" color='#333' size="16"></uni-icons> -->
										</view>
										<view style="color: #868080;" class="" v-else>
											请选择出生日期

										</view>

									</view>

								</view>
								<uni-icons color="#999999" type="right" size="20"></uni-icons>

							</view>
						</picker>
					</view>


					<view class=" myNmae flex-between higeys">
						<view class="flex-wujustify">
							<view style="width:180rpx;">
								当前身高
							</view>
							<view class="">
								<input class="uni-inputs" type="number" v-model="form.height" placeholder="请输入身高" />
							</view>
						</view>
						<!-- <uni-icons color="#999999" type="right" size="20"></uni-icons> -->

					</view>

				</view>
				<view class="borderTwo" style="padding: 35rpx 40rpx;">
					<view class=" myNmae flex-between ">
						<view class="flex-wujustify " style="width: 500rpx;">
							<view style="width:180rpx;">
								所在学校
							</view>
							<view class="">
								<input class="uni-inputs" type="text" v-model="form.school" placeholder="请输入你毕业/所在学校" />
							</view>
						</view>
						<!-- <uni-icons color="#999999" type="right" size="20"></uni-icons> -->


					</view>


					<view class=" margin-top_40rpx ">
						<view class="margin-bottom_30rpx">
							生活照片
						</view>
						<view class="">
							<sunui-upimg1 class="margin-top_20rpx" :border="'1px dashed #bfbfbf'"
								:formData="imgFormData" :storageMode="storageMode" :header="header"
								:size="['200rpx', '200rpx']" btnName="上传生活照片" :uploadServerUrl="upPicUrl"
								ref="selectimgandupload" @uploaded="imgLoaded" @change="imgsChange"
								:maxFileNumber="5"><template v-slot:icon>
									<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
								</template></sunui-upimg1>
						</view>


					</view>
					<view class=" margin-top_40rpx ">
						<view class="margin-bottom_30rpx">
							封面图
						</view>
						<view class="">
							<sunui-upimg1 class="margin-top_20rpx" :border="'1px dashed #bfbfbf'"
								:formData="imgFormData3" :storageMode="storageMode" :header="header"
								:size="['200rpx', '200rpx']" btnName="上传生活照片" :uploadServerUrl="upPicUrl3"
								ref="selectimgandupload3" @uploaded="imgLoaded3" @change="imgsChange3"
								:maxFileNumber="1"><template v-slot:icon>
									<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
								</template></sunui-upimg1>
						</view>


					</view>
					<view class=" margin-top_40rpx ">
						<view class="margin-bottom_30rpx">
							背景详情
						</view>
						<view class="">
							<sunui-upimg1 class="margin-top_20rpx" :border="'1px dashed #bfbfbf'"
								:formData="imgFormData4" :storageMode="storageMode" :header="header"
								:size="['200rpx', '200rpx']" btnName="上传生活照片" :uploadServerUrl="upPicUrl4"
								ref="selectimgandupload4" @uploaded="imgLoaded4" @change="imgsChange4"
								:maxFileNumber="5"><template v-slot:icon>
									<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
								</template></sunui-upimg1>
						</view>


					</view>
					<view class=" margin-top_40rpx">
						<view class="margin-bottom_30rpx">
							个性标签
						</view>
						<view v-if="!form.label" class="voiceIntroduction flex" @click="AddTagsFn()">
							+ 添加标签
						</view>
						<view v-if="form.label" class="voiceIntroduction flex" @click="AddTagsFn(form.label)">
							✔ 已添加
						</view>

					</view>
					<view class="next flex" @click="nextFn(2)">
						下一步
					</view>

				</view>
			</view>
			<!-- 上传身份证 -->
			<view class="identityAuthentication" v-show="step==2">
				<!-- 身份证 姓名 -->
				<view class="card">
					<view class="myNmae">
						<view class=" ">
							身份证姓名
						</view>
						<view class="">
							<input class="uni-inputsa" type="text" v-model="form1.name" placeholder="请输入姓名/称呼" />
						</view>


					</view>
					<view class="myNmae">
						<view class=" ">
							身份证号码
						</view>
						<view class="">
							<input class="uni-inputsa" type="text" v-model="form1.idNo "
								placeholder="请输入身份证号码" />
						</view>


					</view>

				</view>
				<view class="card flex-around">
					<view class="header">


						<view class="headerText">

							请确保填写的身份证信息 <text style="color: #1890FF;font-size: 14px;"> 真实有效</text>
						</view>

						<!-- 	<view class="facade">
							<view class="upLoad">
							
								<sunui-upimg1 :formData="imgFormData1" :storageMode="storageMode" :header="header"
									:size="['338rpx', '683rpx']" btnName="点击上传/正面" :uploadServerUrl="upPicUrl1"
									ref="selectimgandupload1" @uploaded="imgLoaded1" @change="imgsChange1"
									:maxFileNumber="1">
									<template v-slot:icon>
										<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
									</template></sunui-upimg1>
							</view>
							<image class="avater" :src="behind" mode=""></image>

						</view> -->
						<!-- 
						<view class="nationalEmblem">
							<view class="upLoad ">

								<sunui-upimg1 :formData="imgFormData2" :storageMode="storageMode" :header="header"
									:size="['338rpx', '683rpx']" btnName="点击上传/国徽面" :uploadServerUrl="upPicUrl2"
									ref="selectimgandupload2" @uploaded="imgLoaded2" @change="imgsChange2"
									:maxFileNumber="1">
									<template v-slot:icon>
										<uni-icons type="camera-filled" color="#1890FF" size="40"></uni-icons>
									</template></sunui-upimg1>

							</view>
							<image class="avater" :src="positive" mode=""></image>

						</view> -->

						<view class="illustrate">
							<text>
								根据相关法律规定，需要通过实名认证才能进行发布任务，您的证件信息我们将严格保密~

							</text>
						</view>
					</view>

				</view>

				<view class="flex">
					<!-- 	<view class="pre flex " style="margin: 0 20rpx;" @click="preFn(1)">
						上一步
					</view> -->
					<view class="nextRegistration flex " style="margin: 0 20rpx;width: 100%;" @click="nextFn(4)">
						完成
					</view>
				</view>
				<view style="height: 30rpx;" class="">

				</view>

			</view>
			<!-- 开始认证 -->
			<view class="" v-if="step==3">
				<image v-if="step==3&&!isCertified"
					src="http://yunhunjian123.oss-cn-shanghai.aliyuncs.com/2024-06-17/19cfc202406171824408430.png"
					mode="aspectFill"></image>





				<view>
					<view v-if='form1.authentication_img' @click="handlerSuccess()">
						<image v-if="step==3&&isCertified" :src="form1.authentication_img" mode="aspectFit"></image>
					</view>

				</view>

				<view class="flex margin-top_40rpx">
					<view class="pre flex " style="margin: 0 20rpx;" @click="preFn(2)">
						上一步
					</view>
					<view class="next flex " v-if="!isCertified" style="margin: 0 20rpx;width: 100%;"
						@click="nextFn(4)">
						开始认证
					</view>
					<view class="next flex " v-if="isCertified" style="margin: 0 20rpx;width: 100%;" @click="nextFn(4)">
						认证完成
					</view>
				</view>
			</view>
			<!-- 认证完成 -->
			<view class="" v-if="step==4">
				<view class="flex-column margin-bottom_20rpx">
					<image :src="toExamine" mode="aspectFit"></image>
					<view class="font-weight_bold font40 margin-bottom_10rpx">
						恭喜你认证成功
					</view>
					<view class="">
						<text
							style="color: #999999;">恭喜你认证成功，请开启新的世界把</text>
					</view>
				</view>

				<view class="flex">
					<view v-if="userInfoObject.is_authentication==3" class="pre flex " style="margin: 0 20rpx;"
						@click="preFn(1,'reCertification')">
						重新认证
					</view>
			<view  class="pre flex " style="margin: 0 20rpx;"
				@click="improveInformation()">
				继续完善资料
			</view>
					<view class="next flex " style="margin: 0 20rpx;width: 100%;" @click="returnHomepageFn()">
						返回首页
					</view>
				</view>

			</view>
		</view>
		<sunui-popup ref="modifyEmployeeInfo">
			<template v-slot:content>


			</template>
		</sunui-popup>

	</view>
</template>

<script>
	import MumuRecorder from '@/uni_modules/mumu-recorder/components/mumu-recorder/mumu-recorder.vue'
	import bowCamera from '@/uni_modules/bow-camera/components/bow-camera/bow-camera.vue';
	import soundRecording from '@/components/sound-recording/sound-recording.vue'
	import avatar from "@/components/yq-avatar/yq-avatar.vue";
	import proGress from '@/components/progress3/progress.vue'
	export default {
		components: {
			proGress,
			avatar,
			soundRecording,
			bowCamera,
			MumuRecorder,

		},
		data() {
			return {
				toExamine: this.$img.toExamine,
				behind: this.$img.behind,
				positive: this.$img.positive,
				userInfo: uni.getStorageSync("userInfo"),
				Steps: ['实名认证', '完成'],
				Showcamera: true,
				img: '',
				watermark: [{
						type: 'text',
						x: 20,
						y: 40,
						font_color: "#fff",
						font_size: 20,
						text: '程序员毕业会'
					},
					{
						type: 'text',
						x: 15,
						y: 100,
						font_color: "#fff",
						font_size: 50,
						text: '你好呀'
					},
				],

				StepInfo: {
					Current: 0,
					Sum: 2
				},
				form: {
					// sms_code:'',

					age: '',
					// 昵称
					nickname: '',
					// 语音
					speech: '',
					phoneNumber: '',
					// 个人介绍
					introduce: '',
					// 性别
					sex: '1',
					// 生日
					birthday: '',
					// 身高
					height: '',
					// 学校
					school: '',
					// 生活照片
					img: '',
					// 标签
					label: '',
					avatar: '',
					// 封面图
					cover_image: '',
					// 背景图
					background_img: '',

				},
				form1: {
					name: "",
					// id_card_front: "",
					// id_card_back: '',
					idNo: "",
					// authentication_img: ""
				},
				imgFormData: null,
				urls: [this.$img.Uploadavatar, this.$img.Uploadavatar],
				storageMode: "2",
				header: null,
				upPicUrl: null,
				img: [],
				imgStr: [],

				imgFormData1: null,
				upPicUrl1: null,
				img1: [],
				imgStr1: [],


				imgFormData2: null,
				upPicUrl2: null,
				img2: [],
				imgStr2: [],

				imgFormData3: null,
				upPicUrl3: null,
				img3: [],
				imgStr3: [],

				imgFormData4: null,
				upPicUrl4: null,
				img4: [],
				imgStr4: [],

				step: 2,

				yeartime: '',
				//选择的月份
				monthtime: '',
				//选择的天数
				daytime: '',

				date: null,


				currentTime: '1',
				// 是否认证
				isCertified: false,
				userInfoObject: {},
				img: '',
				disableCode: false,
				count: 0


			}
		},
		onLoad() {


			// this.userInfoFn()

			if (uni.getStorageSync("speech")) {
				this.$sun.toast('语音上传成功' + uni.getStorageSync("speech"), 'none', 2000)

				this.form.speech = uni.getStorageSync("speech")

				setTimeout(() => {
					uni.removeStorageSync('speech')
				}, 1000)
			}
			this.form.avatar = this.userInfo.avatar
			this.form.nickname = this.userInfo.nickname
		},

		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			},

			currentTimeFn() {
				return function(currentIndex) {
					if (currentIndex == '1') {
						// 日
						return 'day';

					} else if (currentIndex == '2') {
						// 月
						return 'month';
					} else if (currentIndex == '3') {
						// 年
						return 'year';
					}
				};
			},





		},
		onShow() {

			this.$at.releaseKey('submit');
			if (uni.getStorageSync("speech")) {
				this.$sun.toast('语音上传成功' + uni.getStorageSync("speech"), 'none')

				this.form.speech = uni.getStorageSync("speech")

				setTimeout(() => {
					uni.removeStorageSync('speech')
				}, 1000)
			}
			if (uni.getStorageSync("tagsList")) {

				this.form.label = uni.getStorageSync("tagsList").join(',')


				// this.form.label = '网红,乒乓球'

			}
		},
		methods: {
			improveInformation(){
				this.$sun.navTo('/pagesA/personalCenter/realAuthentication')
			},
			// 验证码码倒计60秒
			countDown(seconds) {
				this.count = seconds;
				var countdownTimer = setInterval(() => {
					this.count--;
					if (this.count === 0) {
						clearInterval(countdownTimer);
						this.disableCode = false;
						// 在这里可以触发验证码过期后的操作
					}
				}, 1000);
			},
			// 注册获取验证码
			async getVerificationCode() {
				if (!this.disableCode) {

					if (/^1[3456789]\d{9}$/.test(this.form.phoneNumber)) {
						const result = await this.$http.post({
							url: this.$api.sendSmsRequest,
							data: {

								phone: this.form.phoneNumber
							}
						});

						if (result.code == 0) {

							this.disableCode = true;
							this.countDown(60);
						} else {
							this.$sun.toast(result.message, 'none');
						}

					} else {
						this.$sun.toast('请填写正确的手机号', 'none');
					}
				}
			},
			radioChange(e) {

				console.log(e)
				this.form.sex = e.detail.value

			},
			handlerSuccess() {

				uni.chooseImage({

					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					success: (res) => {
						for (let i = 0; i < res.tempFilePaths.length; i++) {
							uni.getImageInfo({
								src: res.tempFilePaths[i],
								success: (image) => {
									console.log(image.width);
									console.log(image.height);
									this.imgWidth = image.width
									this.imgHeight = image.height
									uni.uploadFile({
										url: this.$api.upload,
										filePath: res.tempFilePaths[i],
										name: 'file' || this.fileName,
										formData: {


											getContentType: ['image/png', 'image/jpeg'],

										},
										header: null,
										success: uploadRes => {
											console.log('uploadRes-------------',
												uploadRes, 'this.formData', this
												.formData,
												'this.uploadServerUrl', this
												.uploadServerUrl);
											/* 阿里云上传 */


											/* 七牛云上传 */
											uploadRes = JSON.parse(uploadRes.data);

											if (uploadRes.code != 0) {
												// console.log('进入失败uploadRes', uploadRes);
												uni.showToast({
													title: '上传失败 : ' +
														uploadRes.data,
													icon: 'none'
												});
												this.error(index);
												this.isCertified = false
											} else {
												this.form1.authentication_img =
													uploadRes.data.url

												this.isCertified = !this.isCertified


											}

										},
										fail: e => {
											uni.showToast({
												title: '上传失败，请点击图片重试',
												icon: 'none'
											});
											this.error(index);
										}
									});



								}
							});
						}
					}
				});
			},



			cancel() {
				setTimeout(() => {
					this.$refs.modifyEmployeeInfo.close()
				}, 500)

			},
			chooseImage(filePath) {
				console.log('选择的相册图片: ' + filePath);
			},
			confirmPhoto(filePath) {
				this.Showcamera = false

				uni.uploadFile({
					url: this.$api.upload,
					filePath: filePath,
					name: 'file',

					header: null,
					success: uploadRes => {
						console.log('uploadRes-------------',
							uploadRes, 'this.formData', this
							.formData,
							'this.uploadServerUrl', this
							.uploadServerUrl);
						/* 阿里云上传 */


						/* 七牛云上传 */
						uploadRes = JSON.parse(uploadRes.data);

						if (uploadRes.code != 0) {
							// console.log('进入失败uploadRes', uploadRes);
							uni.showToast({
								title: '上传失败 : ' +
									uploadRes.data,
								icon: 'none'
							});
							this.error(index);
						} else {
							this.form1.authentication_img = uploadRes.data.url

							this.$emit('confirm', this.voicePath)
						}

					},
					fail: e => {
						uni.showToast({
							title: '上传照片失败',
							icon: 'none'
						});
						this.error('上传照片失败');
					}
				});
				console.log('拍摄的图片: ' + filePath, this.Showcamera);
			},
			voiceRecordingFn() {

				// this.$refs.modifyEmployeeInfo.show({
				// 	anim: 'bottom',
				// 	position: 'bottom',
				// 	shadeClose: false, //false使用户不能点击其它关闭页面
				// 	topclose: false,
				// 	zIndex: 1000

				// });

				// 原来是录制语音现在改为上传语音
				// this.$sun.navGo('/pagesA/personalCenter/voiceRecording')

				// 上传语音

				//classify 1:全程解说 2：背景音乐
				//选择音频文件
				let that = this;
				uni.chooseFile({
					count: 1, //选取的文件个数限制
					extension: ['.mp3,.m4a'], //可定义允许哪些后缀的文件可被选择
					success: (res) => {
						let tempFiles = res.tempFiles;


						that.filePath = tempFiles[0].path;
						console.log(tempFiles[0].name)
						let markIndex = tempFiles[0].name.lastIndexOf('.');

						let suffix = tempFiles[0].name.substring(markIndex);



						setTimeout(() => {
							if (suffix != '.mp3' && suffix != '.m4a') {
								uni.showToast({
									duration: 1000,
									title: '请上传mp3或者.m4a后缀文件',
									icon: 'none'
								})

								// that.$sun.toast('请上传mp3或者.m4a后缀文件','none')

								return;

							}
							// that.formData.key = new Date().getTime() + Math.floor(Math.random() * 150) + '_.' +
							// 	tempFiles[0].name;

							uni.showLoading({
								title: '上传中...'
							});

							uni.uploadFile({
								name: 'file', //文件上传的name值
								url: this.$api.upload, //接口地址
								// formData: that.formData, //上传额外携带的参数
								filePath: tempFiles[0].path, //临时路径
								success: uploadFileRes => {
									uploadFileRes = JSON.parse(uploadFileRes.data);
									/* uni.showModal({
										content: 'uploadFileRes==>'+uploadFileRes.statusCode+(uploadFileRes.statusCode==200),
										
									}); */

									// return;

									if (uploadFileRes.code != 0) {
										uni.showToast({
											title: '上传失败 : ' + uploadFileRes.data,
											icon: 'none'
										});
										uni.hideLoading();
									} else {
										uni.hideLoading();
										this.$sun.toast('上传成功', 'none')
										this.form.speech = uploadFileRes.data.url

									}
								},
								fail: e => {
									uni.showToast({
										title: '上传失败==>' + e,
										icon: 'none'
									});
								}
							});
						}, 1000)
					}
				});



			},
			confirm(e) {
				if (e) {
					this.$sun.toast('语音上传成功', 'none')
					this.form.speech = e
					setTimeout(() => {
						this.$refs.modifyEmployeeInfo.close()
					}, 100)
				} else {
					this.$sun.toast('语音上传失败', 'none')

					setTimeout(() => {
						this.$refs.modifyEmployeeInfo.close()
					}, 100)
				}
			},
			async userInfoFn() {
				const result = await this.$http.post({
					url: this.$api.userInfo,
					data: {




					},
					headers: {
						'Authorization': this.userInfo.token
					}

				})

				if (result.code == 0) {
					wx.setStorageSync('userInfo', result.data);
					console.log('data', result.data);
					this.userInfoObject = result.data

					this.step = 4
					this.StepInfo.Current = 100




				}
			},
			returnHomepageFn() {
				this.$sun.navBack()
			},
			clk(index) {
				this.$refs.avatar.fChooseImg(index, {
					selWidth: "300upx",
					selHeight: "300upx",
					expWidth: '260upx',
					expHeight: '260upx'
				});
			},
			AddTagsFn(label = '') {
				console.log(label)
				this.$sun.navGo('/pagesA/personalCenter/characteristicLabels', {
					itemLabel: label
				})
			},
			// 日期获取
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;

				return `${year}-${month}-${day}`;

			},

			bindDateChange(e) {


				this.createTime = e.detail.value
				console.log(e.detail.value)
				this.form.birthday = e.detail.value
				this.date = e.target.value;
				/* 在上面声明变量，split是用来截取字段*/
				this.yeartime = this.date.split('-')[0];
				this.monthtime = this.date.split('-')[1];
				this.daytime = this.date.split('-')[2];


			},
			// 上传图片返回
			imgLoaded(e) {
				console.log(e)

				this.img = [];
				for (let i = 0; i < e.length; i++) {
					this.img.push(e[i].url);
				}


				this.imgStr = this.img

				this.form.img = this.imgStr.length === 1 ? this.imgStr[0].toString() : this.imgStr
					.join(',');
			},
			imgsChange(file) {

				console.log('上传发生改变this.storageMode1111============', this.storageMode, '参数file', file);


				if (file.length) {
					this.upPicUrl = this.$api.upload;
					let filesNmae = 'nmoBackground_01.png'; // this.timeDate + 'png'
					this.imgFormData = {
						file: file,
						getsize: file.size,
						getContentType: ['image/png', 'image/jpeg'],
						getoriginalfilename: filesNmae,
						getName: filesNmae
					};
					this.$nextTick(() => {
						this.$refs.selectimgandupload.upload(); //图片上传
					});
				} else {
					this.form.img = '',
						this.imgStr = []
				}
				// this.niuyunLoop(file,0)

			},

			// 上传图片返回
			imgLoaded1(e) {
				console.log(e)

				this.img1 = [];
				for (let i = 0; i < e.length; i++) {
					this.img1.push(e[i].url);
				}


				this.imgStr1 = this.img1

				this.form1.id_card_front = this.imgStr1.length === 1 ? this.imgStr1[0].toString() : this.imgStr1
					.join(',');
			},
			imgsChange1(file) {




				if (file.length) {
					this.upPicUrl1 = this.$api.upload;
					let filesNmae = 'nmoBackground_01.png'; // this.timeDate + 'png'
					this.imgFormData1 = {
						file: file,
						getsize: file.size,
						getContentType: ['image/png', 'image/jpeg'],
						getoriginalfilename: filesNmae,
						getName: filesNmae
					};
					this.$nextTick(() => {
						this.$refs.selectimgandupload1.upload(); //图片上传
					});
				} else {
					this.form1.id_card_front = '',
						this.imgStr1 = []
				}
				// this.niuyunLoop(file,0)

			},



			// 上传图片返回
			imgLoaded2(e) {
				console.log(e)

				this.img2 = [];
				for (let i = 0; i < e.length; i++) {
					this.img2.push(e[i].url);
				}


				this.imgStr2 = this.img2

				this.form1.id_card_back = this.imgStr2.length === 1 ? this.imgStr2[0].toString() : this.imgStr2
					.join(',');
			},
			imgsChange2(file) {




				if (file.length) {
					this.upPicUrl2 = this.$api.upload;
					let filesNmae = 'nmoBackground_01.png'; // this.timeDate + 'png'
					this.imgFormData2 = {
						file: file,
						getsize: file.size,
						getContentType: ['image/png', 'image/jpeg'],
						getoriginalfilename: filesNmae,
						getName: filesNmae
					};
					this.$nextTick(() => {
						this.$refs.selectimgandupload2.upload(); //图片上传
					});
				} else {
					this.form1.id_card_back = '',
						this.imgStr2 = []
				}
				// this.niuyunLoop(file,0)

			},
			// 上传图片返回
			imgLoaded3(e) {
				console.log(e)

				this.img3 = [];
				for (let i = 0; i < e.length; i++) {
					this.img3.push(e[i].url);
				}


				this.imgStr3 = this.img3

				this.form.cover_image = this.imgStr3.length === 1 ? this.imgStr3[0].toString() : this.imgStr3
					.join(',');
			},
			imgsChange3(file) {




				if (file.length) {
					this.upPicUrl3 = this.$api.upload;
					let filesNmae = 'nmoBackground_01.png'; // this.timeDate + 'png'
					this.imgFormData3 = {
						file: file,
						getsize: file.size,
						getContentType: ['image/png', 'image/jpeg'],
						getoriginalfilename: filesNmae,
						getName: filesNmae
					};
					this.$nextTick(() => {
						this.$refs.selectimgandupload3.upload(); //图片上传
					});
				} else {
					this.form.cover_image = '',
						this.imgStr3 = []
				}
				// this.niuyunLoop(file,0)

			},
			// 上传图片返回
			imgLoaded4(e) {
				console.log(e)

				this.img4 = [];
				for (let i = 0; i < e.length; i++) {
					this.img4.push(e[i].url);
				}


				this.imgStr4 = this.img4

				this.form1.background_img = this.imgStr4.length === 1 ? this.imgStr4[0].toString() : this.imgStr4
					.join(',');
			},
			imgsChange4(file) {




				if (file.length) {
					this.upPicUrl4 = this.$api.upload;
					let filesNmae = 'nmoBackground_01.png'; // this.timeDate + 'png'
					this.imgFormData4 = {
						file: file,
						getsize: file.size,
						getContentType: ['image/png', 'image/jpeg'],
						getoriginalfilename: filesNmae,
						getName: filesNmae
					};
					this.$nextTick(() => {
						this.$refs.selectimgandupload4.upload(); //图片上传
					});
				} else {
					this.form1.background_img = '',
						this.imgStr4 = []
				}
				// this.niuyunLoop(file,0)

			},
			nextFn(index) {

				this.$at.uniDoFunc({
					key: 'submit',
					success: async () => {
						this.$at.lockKey('submit');
						if (this.step == 1) {
							console.log(this.form)
							// 登录 需要进行判断当前账号密码 和账号归属店铺及角色是否又选择
							if (!this.form.nickname) {
								this.$sun.toast("请填写昵称", 'none')
								this.$at.releaseKey('submit');
							} else if (!this.form.avatar) {
								this.$sun.toast("请上传头像", 'none')
								this.$at.releaseKey('submit');
							}
							//  else if (!this.form.label) {
							// 	this.$sun.toast("请选择标签", 'none')
							// 	this.$at.releaseKey('submit');
							// }
							 else if (!this.form.phoneNumber) {
								this.$sun.toast("请填写你的手机号", 'none')
								this.$at.releaseKey('submit');
							}
							// else if (!this.form.sms_code) {
							// 	this.$sun.toast("请上传你的验证码", 'none')
							// 	this.$at.releaseKey('submit');
							// }
							else if (!this.form.introduce) {
								this.$sun.toast("请填写个人介绍", 'none')
								this.$at.releaseKey('submit');
							} else if (!this.form.birthday) {
								this.$sun.toast("请选择你的生日", 'none')
								this.$at.releaseKey('submit');
							} else if (!this.form.height) {
								this.$sun.toast("请填写你的身高", 'none')
								this.$at.releaseKey('submit');
							} else if (!this.form.school) {
								this.$sun.toast("请输入你的学校", 'none')
								this.$at.releaseKey('submit');
							}
							//  else if (!this.form.img) {
							// 	this.$sun.toast("请上传生活照片", 'none')
							// 	this.$at.releaseKey('submit');
							// } 
							else {
								this.step = index
								if (this.step == 2) {
									// this.$set(this.StepInfo, 'Current',JSON.parse(JSON.stringify(33.4)));
									this.StepInfo.Current = JSON.parse(JSON.stringify(33.4))


									console.log(this.StepInfo)
								} else if (this.step == 3) {
									this.StepInfo.Current = 66.7
								} else if (this.step == 4) {
									this.StepInfo.Current = 100
								}

								this.$at.releaseKey('submit');
							}
						} else if (this.step == 2) {
                            console.log(this.form1.idNo)
							// 登录 需要进行判断当前账号密码 和账号归属店铺及角色是否又选择
							if (!(/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}(\d|X|x)$/
									.test(this.form1.idNo))) {
								this.$sun.toast("请填写身份证号码或者身份证不正确", 'none')
								this.$at.releaseKey('submit');
							} else if (!this.form1.name) {
								this.$sun.toast("请填写身份证姓名", 'none')
								this.$at.releaseKey('submit');
							} else {
								console.log(this.form1)
								
								// if (this.step == 2) {
								// 	this.StepInfo.Current = 33.4
								// } else if (this.step == 3) {
								// 	this.StepInfo.Current = 66.7
								// } else if (this.step == 4) {
								// 	this.StepInfo.Current = 100
								// }
							
								this.$at.releaseKey('submit');
								
								
								const formAll = {
								
									...this.form1
								}
								
								
								console.log(formAll)
								
								const result = await this.$http.post({
									url: this.$api.idenauthen,
									data: {
										...formAll,
										userId:this.userInfo.id
								
									},
									headers: {
										'Authorization': this.userInfo.token
									}
								
								})
								if (result.code == 0) {
									
									this.userInfoFn()
								
									this.$sun.toast(result.message, 'none')
								

								
								} else {
									this.$sun.toast(result.message+'-'+result.data, 'none')
								}
							}
						} else if (this.step == 4) {
							
							this.$at.releaseKey('submit');
							const formAll = {
							
								...this.form1
							}
							
							
							console.log(formAll)
							
							const result = await this.$http.post({
								url: this.$api.authentication,
								data: {
									...formAll
							
								},
								headers: {
									'Authorization': this.userInfo.token
								}
							
							})
							if (result.code == 0) {
							
								this.$sun.toast(result.message, 'none')
							
								uni.removeStorageSync('tagsList')
							
							
							
								// 如果是认证完成
								console.log(this.form1)
								this.step = index
								if (this.step == 2) {
									this.StepInfo.Current = 33.4
								} else if (this.step == 3) {
									this.StepInfo.Current = 66.7
								} else if (this.step == 4) {
									this.StepInfo.Current = 100
							
									// this.userInfoFn()
								}
							
							
							
							
							
							} else {
								this.$sun.toast(result.message, 'none')
							}
							
							// 如果是开始认证
							// if (!this.isCertified) {
							// 	this.Showcamera = true

							// 	this.$at.releaseKey('submit');

							// 	// 掉拍照方法
							// 	this.handlerSuccess()


							// } else {
								


							// }



						}
					}
				});





			},
			async myUpload(rsp) {
				this.$set(this.urls, rsp.index, rsp.path);
				console.log(rsp)
				this.avatarObj = rsp
				if (this.storageMode == 2) {
					uni.uploadFile({
						url: this.$api.upload, //仅为示例，非真实的接口地址
						filePath: this.avatarObj.path,
						name: 'file',
						formData: {

						},
						success: (res) => {
							if (res.statusCode == 200) {
								console.log('uploadImage success, res is:', res)
								uni.hideLoading();
								uni.showToast({
									title: '上传成功',
									icon: 'success',
									duration: 1000
								})
								this.upLoadStatus = '上传成功'
								this.form.avatar = JSON.parse(res.data).data.url
								console.log(this.form.avatar)
							}



						},
						fail: (err) => {
							if (this.pageVisible) {
								console.log('uploadImage fail', err);
								uni.hideLoading();
								uni.showModal({
									content: err.errMsg,
									showCancel: false
								});
							}
						},
					});
				} else {
					const ts = new Date().getTime();
					// const ua = navigator.userAgent;
					const us = {
						ts,
						// ua
					};
					let url = 'https://yjykmaster.admin168.net/door-massage/massage/upload/alyOssSignature' +
						`${object2Url(us)}`;
					const res = await this.$http.get({
						url: url,
						data: {
							us: us
						}
					});

					let markIndex = this.avatarObj.path.lastIndexOf('.');
					let suffix = this.avatarObj.path.substring(markIndex);
					let date = new Date().getTime();
					wx.uploadFile({
						url: res.data.host, //上传的路径
						filePath: this.avatarObj.path,
						name: 'file',
						formData: {
							name: this.avatarObj.path,
							key: date + suffix, //上传图片的名字和路径（默认路径根目录，自定义目录：xxx/xxx.png）
							policy: res.data.policy,
							OSSAccessKeyId: res.data.accessId,
							success_action_status: "200",
							signature: res.data.signature,
						},
						header: {
							'Access-Control-Allow-Origin': '*',
							'x-oss-callback-Authorization': 'access_token'
						},
						success: (result) => {
							console.log('chooseImage success, temp path is: ', res)

							let url = res.data.host + '/' + date + suffix;
							console.log(url)

							this.form.avatar = url
							if (url) {
								this.upLoadStatus = '上传成功'
							}
							wx.showToast({
								title: "上传成功",
								icon: 'success',
								duration: 1000
							})

						},
						fail: function({
							errMsg
						}) {
							console.log('upladImage fail, errMsg is: ', errMsg)
							wx.showToast({
								title: "上传失败",
								duration: 1000
							})
						},
					})

				}
			},
			preFn(index, name) {
				if (name == 'reCertification') {
					this.$sun.assignObject(this.form, {
						...this.userInfoObject
					})
					this.$sun.assignObject(this.form1, {
						...this.userInfoObject
					})
					this.form.phoneNumber = this.userInfoObject.phone
					const time = this.form.birthday.split('-')
					console.log(time)
					this.yeartime = time[0],
						this.monthtime = time[1],
						this.daytime = time[2]
					this.form.avatar = this.userInfoObject.avatar
					this.$nextTick(() => {
						const img = this.form.img.split(',').map((item) => item.trim());
						console.log(img)
						this.$refs.selectimgandupload.setItems(img);

						const cover_imgList = this.form.cover_image.split(',').map((item) => item.trim());
						console.log(cover_imgList)
						this.$refs.selectimgandupload3.setItems(cover_imgList);

						const background_img = this.form.background_img.split(',').map((item) => item.trim());
						console.log(background_img)
						// this.$refs.selectimgandupload4.setItems(background_img);

						this.$nextTick(() => {
							const cover_imgList = this.form1.id_card_front.split(',').map((item) => item
								.trim());
							console.log(cover_imgList)
							this.$refs.selectimgandupload1.setItems(cover_imgList);


						})
						this.$nextTick(() => {
							const cover_imgList = this.form1.id_card_back.split(',').map((item) => item
								.trim());
							console.log(cover_imgList)
							this.$refs.selectimgandupload2.setItems(cover_imgList);


						})
					})
				}


				if (index == 1) {

					this.$nextTick(() => {
						const img = this.form.img.split(',').map((item) => item.trim());
						console.log(img)
						this.$refs.selectimgandupload.setItems(img);

						const cover_imgList = this.form.cover_image.split(',').map((item) => item.trim());
						console.log(cover_imgList)
						this.$refs.selectimgandupload3.setItems(cover_imgList);

						const background_img = this.form.background_img.split(',').map((item) => item.trim());
						console.log(background_img)
						// this.$refs.selectimgandupload4.setItems(background_img);
					})


				} else if (index == 2) {
					this.$nextTick(() => {
						const cover_imgList = this.form1.id_card_front.split(',').map((item) => item.trim());
						console.log(cover_imgList)
						this.$refs.selectimgandupload1.setItems(cover_imgList);


					})
					this.$nextTick(() => {
						const cover_imgList = this.form1.id_card_back.split(',').map((item) => item.trim());
						console.log(cover_imgList)
						this.$refs.selectimgandupload2.setItems(cover_imgList);


					})
				}


				this.step = index
				if (this.step == 2) {
					this.StepInfo.Current = 33.4
				} else if (this.step == 3) {
					this.Showcamera = true
					this.isCertified = false
					this.StepInfo.Current = 66.7
				} else if (this.step == 4) {
					this.StepInfo.Current = 100
				} else if (this.step == 1) {
					this.StepInfo.Current = 0
				}
			}


		}
	}
</script>

<style lang="less" scoped>
	/deep/.sunui-add-list-remove {
		z-index: 99;
	}

	.bgIndex {


		background-repeat: no-repeat;
		background-size: cover;
		background-image: url('http://yunhunjian123.oss-cn-shanghai.aliyuncs.com/2024-06-17/1f112202406171131397312.png');

		height: 118px;



	}

	.borderTwo {

		border-top: 2rpx solid rgb(236, 235, 235);
	}

	.certificationInformation {
		position: relative;
		margin-top: -20rpx;

		border-radius: 15px;

		background: rgb(255, 255, 255);

		.avatar {
			width: 160rpx;
			height: 160rpx;
			position: absolute;
			left: 30rpx;
			top: -60rpx;
		}

		.identityAuthentication {
			.card {
				width: 708rpx;

				border-radius: 20rpx;
				background: #FFF;
				margin-left: 20rpx;
				padding: 22rpx;
				box-sizing: border-box;

				.header {
					.avaterTitle {
						color: #000;
						font-weight: 600;
						font-size: 32rpx;

					}

					.headerText {
						font-size: 28rpx;
						margin: 15rpx 0 25rpx 0;

					}
				}

				.illustrate {
					margin-top: 24rpx;
					color: #666;
					font-size: 24rpx;
				}

				.nationalEmblem {
					margin: 36rpx 0 24rpx 0;
					position: relative;

					.upLoad {
						z-index: 999;
						position: absolute;
						top: 50%;
						left: 50%;
						transform: translate(-50%, -50%);

						.photo {


							width: 86rpx;
							height: 86rpx;

						}

						.marginTop15 {
							margin-top: 15rpx;
							font-size: 16px;
						}
					}

					.avater {
						width: 682rpx;
						height: 338rpx;
					}
				}

				.facade {
					position: relative;

					.avater {
						width: 682rpx;
						height: 338rpx;
					}

					.upLoad {
						z-index: 999;
						position: absolute;
						top: 50%;
						left: 50%;
						transform: translate(-50%, -50%);

						.photo {


							width: 86rpx;
							height: 86rpx;

						}

						.marginTop15 {
							margin-top: 15rpx;
							font-size: 16px;
						}
					}
				}



			}

			button {
				display: inline-flex !important;
				align-items: center;
				justify-content: center;
				height: 70rpx;
				line-height: 1;
				vertical-align: middle;
				-webkit-appearance: none;
				-webkit-text-size-adjust: 100%;
				box-sizing: border-box;
				font-size: 32rpx;
				white-space: nowrap;
				margin: 0;
				padding: 0rpx 120rpx;
				overflow: visible;
				border-radius: 10rpx;
				font-weight: bold;
				margin: auto;
			}

			.logins {
				width: 708rpx;
				margin-left: 20rpx;
				height: 100rpx;
				color: #fff;
				border-radius: 10px;
				background-color: #1890FF;
			}



		}
	}

	.myNmae {

		background-color: #fff;
		min-width: 50rpx;

		.verificationCode {
			z-index: 999;
			// position: absolute;
			right: 0;
			text-align: center;
			width: 170rpx;
			height: 65rpx;
			line-height: 65rpx;
			border-radius: 100rpx;
			font-size: 20rpx;
			background: #7D5CF7;
			color: #fff;
		}

		.avatar {
			width: 84rpx;
			height: 84rpx;
		}

		input {
			text-align: left;
		}

		.uni-input {

			height: 100rpx;
		}

		.uni-inputsa {
			width: 100%;
			height: 90rpx;
			border-radius: 20rpx;
			background: rgb(245, 245, 245);
			margin: 20rpx 0;
			padding: 0rpx 20rpx;
		}

		.uni-inputs {
			text-align: left !important;
		}

		.backgroundImg {

			height: 154rpx;


		}

	}

	.next {
		margin-top: 25rpx;
		height: 104rpx;
		border-radius: 200rpx;
		color: #fff;
		background: linear-gradient(253.79deg, rgb(234, 80, 235) 14.067%, rgb(136, 42, 243) 99.721%);
	}

	.nextRegistration {
		margin-top: 25rpx;
		height: 104rpx;
		border-radius: 200rpx;
		color: #fff;
		background: linear-gradient(253.79deg, rgb(234, 80, 235) 14.067%, rgb(136, 42, 243) 99.721%);
		position: fixed;
		bottom: 30rpx;
		width: 80% !important;
		z-index: 999;
	}

	.pre {
		margin-top: 25rpx;
		height: 104rpx;
		border-radius: 200rpx;
		width: 100%;
		color: #fff;
		background: linear-gradient(253.79deg, rgb(0, 0, 255) 14.067%, rgb(136, 42, 243) 99.721%);
	}

	.voiceIntroduction {

		height: 76rpx;
		box-sizing: border-box;
		border: 2rpx dashed rgb(210, 176, 255);
		border-radius: 20rpx;
		color: #6C02FA;
		background: rgb(255, 255, 255);
	}


	.higeys {
		height: 100rpx;
		line-height: 100rpx;
	}
</style>